﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using KTool2.Common;

namespace KTool2
{
    /// <summary>
    /// Interaction logic for AboutBox.xaml
    /// </summary>
    public partial class AboutBox : Window
    {
        private volatile static AboutBox instance = null;

        private AboutBox()
        {
            InitializeComponent();

            this.txtVersion.Text += " " + Constant.ASSEMBLY_VERSION;
            this.txtCopyright.Text = Constant.ASSEMBLY_COPYRIGHT;
            this.txtDescription.Text = Constant.ASSEMBLY_DESCRIPTION;
        }

        public static AboutBox Instance
        {
            get
            {
                if (instance == null)
                {
                    System.Threading.Mutex mutex = new System.Threading.Mutex();
                    mutex.WaitOne();

                    if (instance == null)
                    {
                        instance = new AboutBox();
                    }

                    mutex.Close();
                }

                return instance;
            }
        }

        public static bool IsNull
        {
            get { return instance == null; }
        }

        private void txtContact_MouseDown(object sender, MouseButtonEventArgs e)
        {
            System.Diagnostics.Process.Start("mailto:HiepHN60508@fpt.edu.vn?subject=KTool%20v" + Constant.ASSEMBLY_VERSION + ": ");
        }

        protected override void OnClosed(EventArgs e)
        {
            instance = null;
            base.OnClosed(e);
        }

        private void txtWebsite_MouseDown(object sender, MouseButtonEventArgs e)
        {
            System.Diagnostics.Process.Start("http://ktool.codeplex.com");
        }
    }
}
